package ${package.ServiceImpl};

import cn.hutool.core.bean.BeanUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import ${package.Entity}.${entity};
import ${cfg.package}.vo.query.${entity}QryVO;
import ${cfg.package}.vo.request.${entity}ReqVO;
import ${cfg.package}.vo.response.${entity}RepVO;
import ${package.Mapper}.${table.mapperName};
import ${package.Service}.${table.serviceName};
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * ${table.comment!} 服务实现类
 * </p>
 *
 * @author ${author}
 * @since ${date}
 */
@Service
public class ${table.serviceImplName} implements ${table.serviceName} {

    @Autowired
    private ${table.mapperName} ${table.mapperName?uncap_first};

    @Override
    public ${entity}RepVO get(long id) {
        return ${table.mapperName?uncap_first}.get(id);
    }

    @Override
    public List<${entity}RepVO> list(${entity}QryVO qryVO) {
        return ${table.mapperName?uncap_first}.list(qryVO);
    }

    @Override
    public PageInfo<${entity}RepVO> pageList(${entity}QryVO qryVO) {
        PageHelper.startPage(qryVO.getReqPageNum(),qryVO.getReqPageSize());
        return new PageInfo<${entity}RepVO>(${table.mapperName?uncap_first}.list(qryVO));
    }

    @Override
    public void save(${entity}ReqVO reqVO) {
        ${entity} entity = BeanUtil.toBean(reqVO, ${entity}.class);
        entity.preSave();
        ${table.mapperName?uncap_first}.save(entity);
    }

    @Override
    public void update(${entity}ReqVO reqVO) {
        ${entity} entity = BeanUtil.toBean(reqVO, ${entity}.class);
        entity.preUpdate();
        ${table.mapperName?uncap_first}.update(entity);
    }
}
